package code.rocky.reflet;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectTest1 {
    private static final int TURN_NUM = 1000;

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException,
            InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> clz = Class.forName("code.rocky.reflet.Dog");
        Constructor<?> constructor = clz.getConstructor();
        Object obj = constructor.newInstance();
        Method method = clz.getMethod("eat", String.class);
        for (int i = 0; i < TURN_NUM; i++) {
            Object res = method.invoke(obj, "meat" + i);
        }
    }
}
